home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / CDE / I-N / NeXT WDef III.sit / NeXT WDef 3.0 / source / NeXT wdef.c next >
C/C++ Source or Header  |  1993-04-05  |  33KB  |  1,163 lines

  1. /*
  2.             ——————————————————————————————
  3.             My Window Definition Procedure
  4.             ——————————————————————————————
  5.             
  6.             This s that odd window.
  7.             
  8.             ————————
  9.             89/04/20
  10.             ————————
  11.             
  12.             1.0      89/03/31    First draft based on clock window def proc (+A5 games ).
  13.                   89/04/05    Fixed problem with zoom box hilite
  14.                   89/04/06    Fixed zooming
  15.                   89/04/07    Minor changes in draw, chose from two gray patterns
  16.                             to avoid odd mismatches in window dragged onscreen 
  17.                             from offscreen, added proper plainDBox & altDBoxProc 
  18.                             variations, special cased zero width titles.
  19.             1.1      89/04/09    Odd half erased scroll bar startup MPW adjusted
  20.                             [see DrawMyGrowIcon()]
  21.             1.2      89/04/09    Fixed problem with userState updates. Working on colors!
  22.                   89/04/11    Changed size box to chevrons.
  23.                   89/04/12    Made sure inGrow only returned on hilited windows.
  24.                   89/04/20    Added Apples screenBits workaround and scroll area 
  25.                               to grow image.
  26.             2.0   89/11/10  Finished color additions and cleaned up other
  27.                             assorted bugs. JNP
  28.             
  29.                             Changes made by Josh Pritikin ( 11.10.89 ):
  30.                     1. In CalculateMyWindow I added a test to see if we have a color window.
  31.                     2. I removed the ugly StuffHex calls and speeded the pattern packing up.
  32.                     3. I added a gunk of code and special casing to totally support ColorQD!
  33.                     4. The code is admitably gross in some (most) places but it works and should
  34.                         serve as an example of what not to make your code look like.
  35.  
  36.                         GEnie:            J.Pritikin
  37.                         AppleLink:        D4991    ( <- this will change soon )
  38.                         Internet:        6500stom@ucsbuxa.ucsb.edu
  39.                         
  40.             3.0   93/03/22    Updated for full color support. Rewrote code for Think C 5.x.
  41.                             
  42.                             Changes made by Anthony D. Saxton ( 2/26/93 ):
  43.                     1.    Rewrote code throughout for more efficient use of Think C 5.x.
  44.                     2.    Added Color button Icons for 2, 4 and 8 bit modes.
  45.                     3.    Added support for colorized windows as well as Apples "Color" cdev.
  46.                     4.    Added support for ALL documented window types & frames for the others!
  47.                     5.    Corrected Icon bug and added 3D movement!
  48.                     6.    Corrected GoAway button presence in movable dialog windows.
  49.                     
  50.         The Copyright Notice in “CopyRight()” Is Not To Be Removed! Use Of This Code In
  51.         Commercial Software By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
  52.         For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
  53.         Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF. 
  54.         
  55.         All Changes Are Copyright ©1993, by Elenay Creations
  56.                                             5686 Big Sea Street
  57.                                             Las Vegas, NV, USA
  58.                                                                 89110
  59.                                             (702) 453-0270
  60.                             
  61.                         AOL:            Elenay
  62.                         Internet:        elenay_creations@tcs.las-vegas.nv.us
  63.             
  64.             —————————————————————————————————————————————————
  65.               Public Domain 1989 by Appropriate Technology
  66.             —————————————————————————————————————————————————
  67.             Changes - Copyright ©1993 by Elenay™ Creations
  68.             —————————————————————————————————————————————————
  69.             
  70.             Please send a copy of changes/improvements to:
  71.             
  72.             Eric Celeste, Appropriate Technology, 358 North Parkview, Columbus, OH 43209, USA.
  73.             CompuServe: 76146,724. MacNET: Celeste.
  74.             
  75.             ——————————————————————————————————————————————————————————————————————
  76.             Note: This WDEF is coded in THINK C 5.0.3 from Think Technologies
  77.             ——————————————————————————————————————————————————————————————————————
  78.  
  79.  
  80. */
  81.  
  82. #include "NeXT wdef.h"
  83.  
  84. pascal long main( int variation, WindowPtr window, int message, long parameter )
  85. {
  86.     long    result = 0L;            /* the return code for the function */
  87.     
  88.     switch( message ) 
  89.     {
  90.     case( wDraw ):
  91.         DrawMyWindow( variation, window, parameter );
  92.         break;
  93.     case( wHit ):
  94.         result = HitMyWindow( variation, window, parameter );
  95.         break;
  96.     case( wCalcRgns ):
  97.         CalculateMyWindow( variation, window, parameter );
  98.         break;
  99.     case( wNew ):
  100.         SetupWindow( variation, window, parameter );
  101.         break;
  102.     case( wDispose ):
  103.         KillWindow( variation, window, parameter );
  104.         break;
  105.     case( wGrow ):
  106.         GrowMyWindow( variation, window, parameter );
  107.         break;
  108.     case( wDrawGIcon ):
  109.         DrawMyGrowIcon( variation, window, parameter );
  110.         break;
  111.     }
  112.     return( result );
  113. }
  114.  
  115. /*————————————————————
  116.             create an RGB gray of this brightness.
  117. ————————————————————*/
  118. RGBColor PackGray( int brightness )
  119. {
  120.     RGBColor    gray;
  121.     
  122.     gray.red = gray.green = gray.blue = brightness;
  123.     return gray;
  124. }
  125.  
  126. /*————————————————————
  127.             where was my window hit?
  128. ————————————————————*/
  129. long HitMyWindow( int variation, WindowPtr window, long parameter )
  130. {
  131.     Point        hitLocation;
  132.     Rect        windowRect,
  133.                 thisRect;
  134.     long        result;
  135.     
  136.     result = wNoHit;
  137.     
  138.     SetPt( &hitLocation, LoWord( parameter ), HiWord( parameter ) );
  139.     
  140.     if ( PtInRgn( hitLocation, theWindow.strucRgn ) )
  141.     {
  142.         windowRect = (**theWindow.strucRgn).rgnBBox;
  143.         
  144.         if ( PtInRgn( hitLocation, theWindow.contRgn ) )
  145.         {
  146.             result = wInContent;                    /* in the content region */
  147.             
  148.             if ( theWindow.hilited )
  149.                 if ( (variation & 7) == documentProc )
  150.                 {
  151.                     SetRect( &thisRect, windowRect.right - 17, windowRect.bottom - 17,
  152.                                                     windowRect.right - 3, windowRect.bottom - 3 );
  153.                     if ( PtInRect( hitLocation, &thisRect ) )
  154.                         result = wInGrow;
  155.                 }
  156.         } else
  157.         {
  158.             switch( variation & 7 )
  159.             {
  160.             case( documentProc ):
  161.             case( noGrowDocProc ):
  162.             case( movableDBoxProc ):
  163.             
  164.                 result = wInDrag;                        /* in the drag area unless */
  165.                 
  166.                 if ( theWindow.hilited )
  167.                 {
  168.                     if ( theWindow.goAwayFlag && variation != movableDBoxProc )
  169.                     {
  170.                         SetRect( &thisRect, windowRect.left + 5, windowRect.top + 5,
  171.                                                         windowRect.left + 18, windowRect.top + 18 );
  172.                         if ( PtInRect( hitLocation, &thisRect ) )
  173.                             result = wInGoAway;
  174.                     }
  175.                     if ( result == wInDrag && theWindow.zoomFlag )
  176.                     {
  177.                         SetRect( &thisRect, windowRect.right - 17, windowRect.top + 5,
  178.                                                         windowRect.right - 4, windowRect.top + 18 );
  179.                         if ( PtInRect( hitLocation, &thisRect ) && theWindow.dataHandle  )
  180.                         {
  181.                             thisRect = (**theWindow.contRgn).rgnBBox;
  182.                             if ( EqualRect ( &(wDataHandle.stdState), &thisRect ) )
  183.                                 result = wInZoomIn;
  184.                             else
  185.                             {
  186.                                 wDataHandle.userState = thisRect;
  187.                                 result = wInZoomOut;
  188.                             }
  189.                         } /* in the zoom box */
  190.                         
  191.                     } /* still dragging & zoomable */
  192.                     
  193.                 } /* a hilited window */
  194.                 
  195.                 if ( result == wInDrag )
  196.                 {
  197.                     thisRect = windowRect;
  198.                     thisRect.top = (**theWindow.contRgn).rgnBBox.top;
  199.                     if ( PtInRect( hitLocation, &thisRect ) )
  200.                         result = wNoHit;                    // according to Apple's specs
  201.                 } /* below title bar */
  202.                 break;
  203.             }    /* a moveable window */
  204.             
  205.         } /* else not in content region */
  206.         
  207.     } /* in the structure region */
  208.     
  209.     return( result );
  210. } /* end of HitMyWindow() */
  211.  
  212. /*————————————————————
  213.             calculate the regions of my window
  214. ————————————————————*/
  215. CalculateMyWindow( int variation, WindowPtr window, long parameter )
  216. {
  217.     Rect    windowRect,
  218.             portR;
  219.     
  220.     windowRect = window->portRect;
  221.                                             /* a fix for CWindowRecords */
  222.     if( window->portBits.rowBytes < 0xC000 ) /* Color Window? */
  223.         OffsetRect( &windowRect, -window->portBits.bounds.left, -window->portBits.bounds.top );
  224.     else
  225.     {
  226.         portR = (**(*(CWindowPtr)window).portPixMap).bounds;
  227.         OffsetRect( &windowRect, -portR.left, -portR.top );
  228.     }
  229.     
  230.     RectRgn( theWindow.contRgn, &windowRect );
  231.     
  232.     if ( (variation & 8) && !EqualRect( &(wDataHandle.stdState),&windowRect ) )
  233.         wDataHandle.userState = windowRect;
  234.  
  235.     switch ( variation & 7 )
  236.     {
  237.     case ( documentProc ):                        /* a regular window */
  238.     case ( noGrowDocProc ):                        /* a regular window with no growing */
  239.     case ( movableDBoxProc ):                    /* a moveable dialog with no growing or close*/
  240.         OpenRgn();
  241.             InsetRect( &windowRect, -4, -4 );
  242.             windowRect.top -= 16;                /* add room for the title bar */
  243.             MoveTo( windowRect.left, windowRect.top );
  244.             LineTo( windowRect.left, windowRect.bottom-2 );
  245.             LineTo( windowRect.left+2, windowRect.bottom );
  246.             LineTo( windowRect.right, windowRect.bottom );
  247.             LineTo( windowRect.right, windowRect.top+2 );
  248.             LineTo( windowRect.right-2, windowRect.top );
  249.             LineTo( windowRect.left, windowRect.top );
  250.         CloseRgn( theWindow.strucRgn );
  251.         break;
  252.     case ( dBoxProc ):                            /* dialog box variation */
  253.         OpenRgn();
  254.             InsetRect( &windowRect, -8, -8 );
  255.             MoveTo( windowRect.left, windowRect.top );
  256.             LineTo( windowRect.left, windowRect.bottom-2 );
  257.             LineTo( windowRect.left+2, windowRect.bottom );
  258.             LineTo( windowRect.right, windowRect.bottom );
  259.             LineTo( windowRect.right, windowRect.top+2 );
  260.             LineTo( windowRect.right-2, windowRect.top );
  261.             LineTo( windowRect.left, windowRect.top );
  262.         CloseRgn( theWindow.strucRgn );
  263.         break;
  264.     case ( altDBoxProc ):                        /* shadow box variation */
  265.     case ( altDBoxProc | 4 ):                    /* remain consistant W/ Apple */
  266.         OpenRgn();
  267.             InsetRect( &windowRect, -1, -1 );
  268.             MoveTo( windowRect.left, windowRect.top );
  269.             LineTo( windowRect.left, windowRect.bottom );
  270.             LineTo( windowRect.left+2, windowRect.bottom );
  271.             LineTo( windowRect.left+2, windowRect.bottom+2 );
  272.             LineTo( windowRect.right+2, windowRect.bottom+2 );
  273.             LineTo( windowRect.right+2, windowRect.top+2 );
  274.             LineTo( windowRect.right, windowRect.top+2 );
  275.             LineTo( windowRect.right, windowRect.top );
  276.             LineTo( windowRect.left, windowRect.top );
  277.         CloseRgn( theWindow.strucRgn );
  278.         break;
  279.     default:                                /* plain box variation (plainDBox) and others */
  280.         InsetRect( &windowRect, -1, -1 );
  281.         RectRgn( theWindow.strucRgn, &windowRect );
  282.         break;
  283.     }
  284.         
  285. } /* end of CalculateMyWindow() */
  286.  
  287. /*————————————————————
  288.             set up the window
  289. ————————————————————*/
  290. SetupWindow( int variation, WindowPtr window, long parameter )
  291. {
  292.     SysEnvRec    thisWorld;
  293.     OSErr        err;
  294.     GDHandle    thisDevice;
  295.     Rect        thisRect;
  296.     GrafPtr     savePort;   
  297.     GrafPort    tempPort; 
  298.     
  299.     thisDevice = nil;
  300.     theWindow.dataHandle = nil;
  301.     
  302.     theWindow.dataHandle = NewHandle( (long)sizeof( WSDRecord ) );
  303.         
  304.     if ( variation == ( documentProc+8 ) || variation == ( noGrowDocProc+8 ) ||
  305.                                                             variation == ( movableDBoxProc+8 ) )
  306.     {
  307.         theWindow.zoomFlag = true;
  308.         if ( theWindow.dataHandle )
  309.         {        
  310.             err = SysEnvirons( 1, &thisWorld );
  311.             if ( !err && thisWorld.hasColorQD )
  312.             {
  313.                 thisDevice = GetMainDevice();
  314.                 thisRect = (**thisDevice).gdRect;
  315.                 thisRect.top += MBarHeight;
  316.             } else
  317.             {
  318.                 GetPort( &savePort );                /* finding screenBits w/o globals */
  319.                 OpenPort( &tempPort );
  320.                 thisRect = tempPort.portRect;
  321.                 SetPort( savePort ); 
  322.                 ClosePort( &tempPort );
  323.                 thisRect.top += MBarHeight;            /* make way for the menubar */
  324.             }
  325.             InsetRect( &thisRect, 4, 4 );            /* make way for edges */
  326.             thisRect.top += 16;                        /* make way for what's left of title */
  327.             wDataHandle.stdState = thisRect;
  328.             wDataHandle.userState = thisRect;
  329.         }
  330.     } else
  331.         theWindow.zoomFlag = false;
  332.         
  333.     buttonState = 0;
  334.     
  335. } /* end of SetupWindow() */
  336.  
  337. /*————————————————————
  338.             kill the window
  339. ————————————————————*/
  340. KillWindow( int variation, WindowPtr window, long parameter )
  341. {
  342.     if ( theWindow.dataHandle  )
  343.     {
  344.         DisposHandle( theWindow.dataHandle );
  345.         theWindow.dataHandle = nil;
  346.     }
  347. } /* end of KillWindow() */
  348.  
  349. /*————————————————————
  350.             draw the growing outline, the pen is already set
  351. ————————————————————*/
  352. GrowMyWindow( int variation, WindowPtr window, long parameter )
  353. {
  354.     Rect        growingRect;
  355.     
  356.     growingRect = *(RectPtr)parameter;
  357.     
  358.     growingRect.top -= 20;                                    /* out to full size */
  359.     growingRect.left -= 4;
  360.     growingRect.bottom += 4;
  361.     growingRect.right += 4;
  362.     
  363.     FrameRect( &growingRect );                                /* the frame */
  364.     
  365.     growingRect.top += 19;
  366.     
  367.     MoveTo( growingRect.left, growingRect.top );            /* the title bar area */
  368.     LineTo( growingRect.right, growingRect.top );
  369.     
  370.     MoveTo( growingRect.right - 19, growingRect.top );         /* the scroll area */
  371.     LineTo( growingRect.right - 19, growingRect.bottom );
  372.     MoveTo( growingRect.left, growingRect.bottom - 19 );
  373.     LineTo( growingRect.right, growingRect.bottom - 19 );
  374.     
  375. } /* end of GrowMyWindow() */
  376.  
  377. /*————————————————————
  378. draw the size box and the scroll frame
  379. ————————————————————*/
  380. DrawMyGrowIcon( int variation, WindowPtr window, long parameter )
  381. {
  382.     Boolean            hasColorQD;
  383.     Rect            thisRect;
  384.     SysEnvRec        thisWorld;
  385.     RGBColor        myRGB;
  386.     CGrafPtr        wPort;
  387.     GDHandle        aDevice;
  388.     RgnHandle        saveClip,
  389.                     tempRgn;
  390.     AuxWinHandle    theAuxWin;
  391.     
  392.     theAuxWin = nil;
  393.     
  394.     SetPort( window );
  395.     
  396.     if ( !SysEnvirons( 1, &thisWorld ) )
  397.         hasColorQD = thisWorld.hasColorQD;
  398.     else
  399.         hasColorQD = false;
  400.     
  401.     if ( hasColorQD )
  402.     {
  403.         GetAuxWin( window, &theAuxWin );
  404.         if ( theAuxWin )
  405.         {
  406.             
  407. /*        The code below makes sure the System 7 colors are found even when the window color
  408.             table is defined with only 5 colors! This determines if the Grow Icon will be drawn
  409.             in color or b/w. */
  410.                 
  411.             if ( (*(*theAuxWin)->awCTable)->ctSize < 12 )
  412.                 GetAuxWin( nil, &theAuxWin );
  413.                 
  414.             if ( (*(*theAuxWin)->awCTable)->ctSize >= 12 )
  415.                 myRGB =  (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
  416.             else
  417.                 myRGB.red = 0xFFFF;                // Don't force b/w if Color cdev not used…
  418.         }
  419.     }
  420.     
  421. /*————————————————————
  422. draw scroll bar frame
  423. ————————————————————*/
  424.     thisRect = window->portRect;
  425.     thisRect.left = thisRect.right - 15;
  426.     MoveTo( thisRect.left, thisRect.top );
  427.     LineTo( thisRect.left, thisRect.bottom );
  428.  
  429.     thisRect.top = thisRect.bottom - 15;
  430.     thisRect.left = window->portRect.left;
  431.     MoveTo( thisRect.left, thisRect.top );
  432.     LineTo( thisRect.right, thisRect.top );
  433.     
  434.     thisRect.left = thisRect.right - 14;
  435.     thisRect.top++;
  436.     EraseRect( &thisRect );
  437.     
  438.     /*————————————————————
  439.     draw the sizing box 
  440.     ————————————————————*/
  441.  
  442.     saveClip = NewRgn();
  443.     tempRgn = NewRgn();
  444.     GetClip( saveClip );
  445.     
  446.     if ( hasColorQD && window->portBits.rowBytes < 0xC000 )
  447.     {
  448.         thisRect = (**theWindow.contRgn).rgnBBox;
  449.         thisRect.left = thisRect.right - 15;
  450.         thisRect.top = thisRect.bottom - 15;    
  451.         thisRect.right += 1;
  452.         thisRect.bottom += 1;
  453.         GetCWMgrPort( &wPort );
  454.         SetPort( wPort );
  455.     } else
  456.     {
  457.         thisRect.right += 2;
  458.         thisRect.bottom += 2;
  459.     }
  460.  
  461.  
  462.     if ( theWindow.hilited )
  463.     {
  464.         if( hasColorQD )
  465.         {
  466.             aDevice = GetDeviceList();
  467.             do
  468.             {
  469.                 if ( TestDeviceAttribute( aDevice, screenDevice ) &&
  470.                                                     TestDeviceAttribute( aDevice, screenActive ) )
  471.                 {
  472.                     HLock( aDevice );
  473.                     if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
  474.                     {
  475.                         RectRgn( tempRgn, &(**aDevice).gdRect );
  476.                         SectRgn( saveClip, tempRgn, tempRgn );
  477.                         SetClip( tempRgn );
  478.                         if ( (**(**aDevice).gdPMap).cmpSize >= 2 &&
  479.                                                             (myRGB.red|myRGB.green|myRGB.blue))
  480.                             PlotCICN( thisRect,
  481.                                 "\xEA\xAA\xAA\xA8\x95\x41\x55\x48"
  482.                                 "\x95\x4A\x55\x48\x95\x4A\x01\x48"
  483.                                 "\x95\x4A\x2A\x48\x80\x1A\x2A\x48"
  484.                                 "\x8A\xAA\x2A\x48\x9A\xAA\x2A\x48"
  485.                                 "\x95\x55\x2A\x48\x94\x00\x6A\x48"
  486.                                 "\x94\xAA\xAA\x48\x95\xAA\xAA\x48"
  487.                                 "\x95\x55\x55\x48\x80\x00\x00\x18"
  488.                                 "\xFF\xFF\xFF\xF8\x00\x00\x00\x00"
  489.                             );                                        // The Color Grow Icon!
  490.                         else
  491.                             PlotSICN( thisRect, 
  492.                                 "\xFF\xFC\xD1\x52\xAB\xA8\xD3\x12"
  493.                                 "\xAB\x78\x83\x72\xBF\x78\xFF\x72"
  494.                                 "\xAA\x78\xC0\x72\xAF\xF8\xDF\xF2"
  495.                                 "\xAA\xA8\x80\x02\xFF\xFE\x00\x00"
  496.                             );                                        // The b/w Grow Icon!
  497.                     }
  498.                     HUnlock( aDevice );
  499.                 }
  500.             } while ( aDevice = GetNextDevice( aDevice ) );
  501.         } else
  502.             PlotSICN( thisRect, 
  503.                 "\xFF\xFC\xD1\x52\xAB\xA8\xD3\x12"
  504.                 "\xAB\x78\x83\x72\xBF\x78\xFF\x72"
  505.                 "\xAA\x78\xC0\x72\xAF\xF8\xDF\xF2"
  506.                 "\xAA\xA8\x80\x02\xFF\xFE\x00\x00"
  507.             );                                                    // The b/w Grow Icon Again!
  508.     }
  509.  
  510.     SetPort( window );
  511.     SetClip( saveClip );
  512.     DisposeRgn( saveClip );
  513.     DisposeRgn( tempRgn );
  514.  
  515. } /* end of DrawMyGrowIcon() */
  516.  
  517. /*————————————————————
  518.             draw the frame w/ color shadowing.
  519. ————————————————————*/
  520. DrawFrame( PatsPtr pat, Rect frame, int width, Boolean drawColor )
  521. {
  522.     frame.right -= 2;
  523.     frame.bottom -= 2;
  524.     
  525.     PenSize( width, width );
  526.     if ( drawColor )
  527.         RGBForeColor( &pat->cFrameL );
  528.     else
  529.         PenPat( &pat->white );
  530.     FrameRect( &frame );
  531.     
  532.     OffsetRect( &frame, 2, 2 );
  533.     if ( drawColor )
  534.         RGBForeColor( &pat->cFrameD );
  535.     else
  536.         PenPat( &pat->black );
  537.     FrameRect( &frame );
  538.  
  539.     OffsetRect( &frame, -1, -1 );
  540.     if ( drawColor )
  541.         RGBForeColor( &pat->cGray );
  542.     else
  543.         PenPat( &pat->gray );
  544.     FrameRect( &frame );
  545. } /* end of DrawFrame() */
  546.  
  547. /*————————————————————
  548.             draw an empty pane w/ shadowing
  549. ————————————————————*/
  550. DrawPane( PatsPtr pat, Rect thisRect, Boolean drawColor )
  551. {
  552.     /* fill the area with white */
  553.     if ( drawColor )
  554.     {
  555.         RGBForeColor( &pat->cTitle );
  556.         PenPat( &pat->black );
  557.     } else
  558.         PenPat( &pat->white );
  559.     PaintRect( &thisRect );
  560.     
  561.     /* add the bottom shadow */
  562.     PenSize( 1, 1 );
  563.     if ( drawColor )
  564.         RGBForeColor( &pat->cFrameL );
  565.     else
  566.         PenPat( &pat->black );
  567.     MoveTo( thisRect.left+1, thisRect.bottom-1 );
  568.     LineTo( thisRect.right-1, thisRect.bottom-1 );
  569.     LineTo( thisRect.right-1, thisRect.top+1 );
  570.     
  571.     /* add the top shadow */
  572.     if ( drawColor )
  573.         RGBForeColor( &pat->cFrameD );
  574.     MoveTo( thisRect.left, thisRect.bottom-1 );
  575.     LineTo( thisRect.left, thisRect.top );
  576.     LineTo( thisRect.right-1, thisRect.top );
  577. } /* end of DrawPane() */
  578.  
  579. /*————————————————————
  580.             draw the title into the pane.
  581. ————————————————————*/
  582. DrawWindowTitle( WindowPtr window, Rect titleRect, PatsPtr pat, Boolean hilited, Boolean drawColor )
  583. {
  584.     int            saveFont;
  585.     int            saveSize;
  586.     Style        saveFace;
  587.     Str255        windowTitle;
  588.     int            titleWidth;
  589.     RgnHandle    saveClip,
  590.                 myClip;
  591.     GrafPtr        wPort;
  592.     
  593.     GetPort( &wPort );
  594.     saveFont = wPort->txFont;
  595.     saveSize = wPort->txSize;
  596.     saveFace = wPort->txFace;
  597.  
  598.     TextFont( geneva );
  599.     TextSize( 9 );
  600.     TextFace( plain );
  601.     
  602.     GetWTitle( window, windowTitle );
  603.     
  604.     titleWidth = StringWidth( windowTitle );
  605.     
  606.     if ( titleWidth > 0 )
  607.     {
  608.         titleWidth += 12;                        /* enough for edges */
  609.     
  610.         if ( (titleRect.right - titleRect.left) > titleWidth )
  611.             titleRect.right = titleRect.left + titleWidth;
  612.         
  613.         if ( hilited ) DrawPane( pat, titleRect, drawColor );
  614.         
  615.         /* now shrink the box & set the clip region in case of a long title */
  616.         saveClip = NewRgn();
  617.         myClip = NewRgn();
  618.         GetClip( saveClip );
  619.         
  620.         InsetRect( &titleRect, 1, 1 );
  621.         RectRgn( myClip, &titleRect );
  622.         SectRgn( saveClip, myClip, myClip );
  623.         SetClip( myClip );
  624.         
  625.         /* now position ourselves & draw the title */
  626.         PenPat( &pat->black );
  627.         if ( drawColor )
  628.         {
  629.             if ( hilited )
  630.             {
  631.                 RGBForeColor( &pat->cText );
  632.                 RGBBackColor( &pat->cTitle );
  633.             } else
  634.             {
  635.                 RGBForeColor( &pat->cWhite );
  636.                 RGBBackColor( &pat->cGray );
  637.             }
  638.         }
  639.         
  640.         MoveTo( titleRect.left + 5, titleRect.bottom - 2 );
  641.         DrawString( windowTitle );
  642.         
  643.         SetClip( saveClip );
  644.         DisposeRgn( saveClip );
  645.         DisposeRgn( myClip );
  646.                 
  647.     } /* enough of a title to go with */
  648.     
  649.     TextFont( saveFont );
  650.     TextSize( saveSize );
  651.     TextFace( saveFace );
  652. } /* end of DrawWindowTitle() */
  653.  
  654. /*————————————————————
  655.             animate the close icon.
  656. ————————————————————*/
  657. DrawGoAway( Rect frame, Boolean hilited, Boolean drawColor )
  658. {
  659.     if ( hilited  )
  660.     {
  661.         if ( drawColor )
  662.             PlotCICN( frame,
  663.                         "\xBF\xFF\xFF\xF9\xEA\xAA\xAA\xAD\xE5\x55\x55\x4D\xE5\x55\x55\x4D"
  664.                         "\xE5\x55\x55\x4D\xE5\x55\x55\x4D\xE5\x00\x00\x4D\xE4\x55\x56\x4D"
  665.                         "\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\xAA\xAA\x4D"
  666.                         "\xE5\x55\x55\x4D\xE0\x00\x00\x1D\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
  667.                     );    // goAwayDown
  668.         else
  669.             PlotSICN( frame,
  670.                         "\xFF\xFE\xFF\xFF\xEA\xAA\xD5\x53\xEA\xAA\xD5\x53\xE0\x0A\xC5\x53"
  671.                         "\xEA\xBA\xC5\x53\xEA\xBA\xDF\xF3\xEA\xAA\xC0\x03\xFF\xFE\x55\x55"
  672.                     );    // goAwayDown (b/w)
  673.     } else
  674.     {
  675.         if ( drawColor )
  676.             PlotCICN( frame,
  677.                         "\xBF\xFF\xFF\xF9\xD0\x00\x00\x0D\xC5\x55\x55\x6D\xC5\x55\x55\x6D"
  678.                         "\xC5\x55\x55\x6D\xC5\x55\x55\x6D\xC5\x00\x00\x6D\xC4\x55\x56\x6D"
  679.                         "\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\xAA\xAA\x6D"
  680.                         "\xC5\x55\x55\x6D\xCA\xAA\xAA\xAD\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
  681.                     );    // goAwayUp
  682.         else
  683.             PlotSICN( frame,
  684.                         "\xFF\xFE\x80\x03\xAA\xAE\x95\x57\xAA\xAE\x95\x57\xA0\x0E\x85\x57"
  685.                         "\xAA\xBE\x85\x57\xAA\xBE\x8F\xF7\xAA\xAE\xBF\xFF\xFF\xFE\x55\x55"
  686.                     );    //    goAwayUp (b/w)
  687.     }
  688. } /* end of DrawGoAway() */
  689.  
  690. /*————————————————————
  691.             animate the zoom icon.
  692. ————————————————————*/
  693. DrawZoom( Rect frame, Boolean hilited, Boolean drawColor )
  694. {
  695.     if ( hilited )
  696.     {
  697.         if ( drawColor )
  698.             PlotCICN( frame,
  699.                         "\xBF\xFF\xFF\xF9\xEA\xAA\xAA\xAD\xE5\x55\x55\x4D\xE5\x00\x00\x4D"
  700.                         "\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D"
  701.                         "\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\x55\x56\x4D\xE4\xAA\xAA\x4D"
  702.                         "\xE5\x55\x55\x4D\xE0\x00\x00\x1D\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
  703.                     );    //    zoomDown
  704.         else
  705.             PlotSICN( frame,
  706.                         "\xFF\xFE\xFF\xFF\xEA\xAA\xC0\x03\xEA\xBA\xC5\x53\xEA\xBA\xC5\x53"
  707.                         "\xEA\xBA\xC5\x53\xEA\xBA\xCF\xF3\xEA\xAA\xC0\x03\xFF\xFE\x55\x55"
  708.                     );    //    zoomDown (b/w)
  709.     } else
  710.     {
  711.         if ( drawColor )
  712.             PlotCICN( frame,
  713.                         "\xBF\xFF\xFF\xF9\xD0\x00\x00\x0D\xC5\x55\x55\x6D\xC5\x00\x00\x6D"
  714.                         "\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D"
  715.                         "\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\x55\x56\x6D\xC4\xAA\xAA\x6D"
  716.                         "\xC5\x55\x55\x6D\xCA\xAA\xAA\xAD\xBF\xFF\xFF\xF9\x55\x55\x55\x55"
  717.                     );    //    zoomUp
  718.         else
  719.             PlotSICN( frame,
  720.                         "\xFF\xFE\x80\x07\xAA\xAE\x80\x17\xAA\xBE\x85\x57\xAA\xBE\x85\x57"
  721.                         "\xAA\xBE\x85\x57\xAA\xBE\x9F\xF7\xAA\xAE\xFF\xFF\xFF\xFE\x55\x55"
  722.                     );
  723.     }
  724. } /* end of DrawZoom() */
  725.  
  726. /*————————————————————
  727.             draw the specified item
  728. ————————————————————*/
  729. DrawOnce( long param, int var, WindowPtr window, Rect windowRect, PatsPtr pat, Boolean drawColor )
  730. {
  731.     Rect        thisRect;
  732.     
  733.     switch ( (int)param )
  734.     {
  735.     case ( wNoHit ):
  736.         
  737.         thisRect = windowRect;
  738.  
  739.         PenNormal();
  740.         
  741.         /* ——————————————————————————————————————— now for the more specific parts */
  742.         switch ( var & 7 )
  743.         {
  744.         case ( documentProc ):                    /* a regular window */
  745.         case ( noGrowDocProc ):                    /* a regular window with no grow box */
  746.         case ( movableDBoxProc ):                /* a non-modal dialog */
  747.             DrawFrame( pat, thisRect, 2, drawColor );
  748.             InsetRect( &thisRect, 1, 1 );
  749.             
  750.             thisRect.bottom = thisRect.top + 19;
  751.             if ( drawColor )
  752.             {
  753.                 PenPat( &pat->black );
  754.                 RGBForeColor( &pat->cGray );
  755.             } else
  756.                 PenPat( &pat->gray );
  757.             PaintRect( &thisRect );
  758.             PenPat( &pat->black );
  759.             if ( drawColor )
  760.                 RGBForeColor( &pat->cFrameD );
  761.             PenSize( 1, 1 );
  762.             MoveTo( windowRect.left+3, windowRect.top+19 );
  763.             LineTo( windowRect.right-4, windowRect.top+19 );
  764.  
  765.             if ( theWindow.hilited )
  766.             {
  767.                 /* ——————————————————————————————— the goaway box */
  768.                 if ( theWindow.goAwayFlag  && (var & 7) != movableDBoxProc )
  769.                 {
  770.                     SetRect( &thisRect, 
  771.                         windowRect.left     + 3, 
  772.                         windowRect.top         + 3,
  773.                         windowRect.left     + 19,
  774.                         windowRect.top         + 19
  775.                      );
  776.                     DrawPane( pat, thisRect, drawColor );
  777.                     DrawGoAway( thisRect, false, drawColor );        
  778.                 }
  779.                 /* ——————————————————————————————— the zoom box */
  780.                 if ( theWindow.zoomFlag )
  781.                 {
  782.                     SetRect( &thisRect, 
  783.                         windowRect.right     - 19, 
  784.                         windowRect.top         + 3,
  785.                         windowRect.right     - 3,
  786.                         windowRect.top         + 19
  787.                      );
  788.                     DrawPane( pat, thisRect, drawColor );
  789.                     DrawZoom( thisRect, false, drawColor );        
  790.                 }
  791.                 /* ——————————————————————————————— the title */
  792.                 SetRect( &thisRect, 
  793.                     windowRect.left     + 20, 
  794.                     windowRect.top         + 3,
  795.                     windowRect.right     - (( theWindow.zoomFlag ) ? 21 : 3),
  796.                     windowRect.top         + 17
  797.                  );
  798.                 PenSize( 1, 1 );
  799.                 if ( thisRect.right - thisRect.left > 0 )
  800.                     DrawWindowTitle( window, thisRect, pat, true, drawColor );
  801.             } else
  802.             {
  803.                 /* ——————————————————————————————— the blank title bar */
  804.                 if ( !drawColor )
  805.                 {
  806.                     thisRect.top += 2;
  807.                     thisRect.left += 2;
  808.                     thisRect.bottom = thisRect.top + 14;
  809.                     thisRect.right -=2;
  810.                     DrawPane( pat, thisRect, drawColor );
  811.                 }
  812.                 /* ——————————————————————————————— the title */
  813.                 SetRect( &thisRect, 
  814.                     windowRect.left     + 20, 
  815.                     windowRect.top         + 3,
  816.                     windowRect.right     - 19,
  817.                     windowRect.top         + 17
  818.                  );
  819.                 DrawWindowTitle( window, thisRect, pat, false, drawColor );
  820.             }
  821.             break;
  822.         
  823.         case ( dBoxProc ):                        /* dialog box variation */
  824.             DrawFrame( pat, thisRect, 4, drawColor );
  825.             thisRect.right -= 2;
  826.             thisRect.bottom -= 2;
  827.             OffsetRect( &thisRect, 1, 1 );
  828.             InsetRect( &thisRect, 5, 5 );
  829.             PenSize( 2, 2 );
  830.             if ( drawColor )
  831.             {
  832.                 PenPat( &pat->black );
  833.                 RGBForeColor( &pat->cFrameL );
  834.             } else
  835.                 PenPat( &pat->white );
  836.             FrameRect( &thisRect );
  837.             break;
  838.         case ( altDBoxProc ):                    /* shadow box variation */
  839.         case ( altDBoxProc | 4 ):                /* remain consistant w/ Apple */
  840.             thisRect.right -= 2;
  841.             thisRect.bottom -= 2;
  842.             FrameRect( &thisRect );
  843.             PenSize( 2, 2 );
  844.             if ( drawColor )
  845.                 RGBForeColor( &pat->cGray );
  846.             MoveTo( thisRect.left + 2, thisRect.bottom );
  847.             LineTo( thisRect.right, thisRect.bottom );
  848.             LineTo( thisRect.right, thisRect.top + 2 );
  849.             break;
  850.         default:                                /* plain box variation (plainDBox) and others */
  851.             PenPat( &pat->black );
  852.             FrameRect( &thisRect );
  853.             break;
  854.         }
  855.         
  856.         break;
  857.         
  858.     case ( wInGoAway ):
  859.     
  860.         SetRect( &thisRect,                         /* just toggle the goAway */
  861.             windowRect.left     + 3, 
  862.             windowRect.top         + 3,
  863.             windowRect.left     + 19,
  864.             windowRect.top         + 19
  865.          );
  866.         buttonState = !buttonState;
  867.         DrawGoAway( thisRect, buttonState, drawColor );        
  868.         break;
  869.         
  870.     case ( wInZoomIn ):
  871.     case ( wInZoomOut ):
  872.  
  873.         SetRect( &thisRect,                         /* just toggle the zoomBox */
  874.             windowRect.right     - 19, 
  875.             windowRect.top         + 3,
  876.             windowRect.right     - 3,
  877.             windowRect.top         + 19
  878.          );
  879.         buttonState = !buttonState;
  880.         DrawZoom( thisRect, buttonState, drawColor );
  881.         break;
  882.         
  883.     default:
  884.         break;
  885.         
  886.     }
  887. } /* end of DrawOnce() */
  888.  
  889. /*————————————————————
  890.             drawing my window
  891. ————————————————————*/
  892. DrawMyWindow( int var, WindowPtr window, long param )
  893. {
  894.     SysEnvRec        thisWorld;
  895.     CGrafPtr        wPort,
  896.                     savePort;
  897.     Boolean            hasColorQD;
  898.     
  899.     PenState        savePen;
  900.     RGBColor        savePnClr,
  901.                     saveBkClr;
  902.     PixPatHandle    savePnPat,
  903.                     saveBkPat,
  904.                     saveFillPat;
  905.     RgnHandle        saveClip,
  906.                     tempRgn;
  907.  
  908.     PatsRec            patStore;
  909.     PatsPtr            pat;
  910.     
  911.     Rect            windowRect;
  912.     GDHandle        aDevice;
  913.     AuxWinHandle    theAuxWin;
  914.     
  915.     theAuxWin = nil;
  916.     savePnPat = nil;
  917.     
  918.     if ( !theWindow.visible ) return;
  919.     
  920.     pat = &patStore;
  921.         
  922.     if ( !SysEnvirons( 1, &thisWorld ) )
  923.         hasColorQD = thisWorld.hasColorQD;
  924.     else
  925.         hasColorQD = false;
  926.         
  927.     
  928.     if ( hasColorQD )
  929.     {
  930.         GetPort( &savePort );
  931.         GetCWMgrPort( &wPort );
  932.         SetPort( wPort );
  933.         
  934.         savePnPat = NewPixPat();
  935.         saveBkPat = NewPixPat();
  936.         saveFillPat = NewPixPat();
  937.         
  938.         CopyPixPat( wPort->pnPixPat, savePnPat );
  939.         CopyPixPat( wPort->bkPixPat, saveBkPat );
  940.         CopyPixPat( wPort->fillPixPat, saveFillPat );
  941.         GetForeColor( &savePnClr );
  942.         GetBackColor( &saveBkClr );
  943.         
  944.         pat->cBlack = PackGray( 0 );
  945.         pat->cDark = PackGray( 0x4000 );
  946.         pat->cGray = PackGray( 0x8000 );
  947.         pat->cLight = PackGray( 0xC000 );
  948.         pat->cWhite = PackGray( 0xFFFF );
  949.         
  950.         GetAuxWin( window, &theAuxWin );
  951.         if ( theAuxWin )
  952.         {
  953.             HLock( (*theAuxWin)->awCTable );
  954.                                 
  955.             pat->cText = (*(*theAuxWin)->awCTable)->ctTable[2].rgb;
  956.             pat->cHilite = (*(*theAuxWin)->awCTable)->ctTable[3].rgb;
  957.             pat->cTitle = (*(*theAuxWin)->awCTable)->ctTable[4].rgb;
  958.             
  959.     /*        The code below makes sure the System 7 colors are found even when the window color
  960.                 table is defined with only 5 colors! This defines the outline colors of the
  961.                 frame and buttons.    */
  962.                 
  963.             if ( (*(*theAuxWin)->awCTable)->ctSize < 12 )
  964.                 GetAuxWin( nil, &theAuxWin );
  965.             if ( (*(*theAuxWin)->awCTable)->ctSize >= 12 )
  966.             {            
  967.                 pat->cFrameL =  (*(*theAuxWin)->awCTable)->ctTable[11].rgb;
  968.                 pat->cFrameD =  (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
  969.                 if ( !(pat->cFrameD.red | pat->cFrameD.green | pat->cFrameD.blue) )
  970.                     hasColorQD=false;
  971.             } else
  972.             {
  973.                 pat->cFrameL = pat->cLight;
  974.                 pat->cFrameD = pat->cDark;
  975.             }
  976.             HUnlock( (*theAuxWin)->awCTable );
  977.         } else
  978.         {
  979.             pat->cText = pat->cBlack;
  980.             pat->cHilite = pat->cLight;
  981.             pat->cTitle = pat->cWhite;
  982.         }
  983.     }
  984.     
  985.     saveClip = NewRgn();
  986.     tempRgn = NewRgn();
  987.     GetClip( saveClip );
  988.     windowRect = (**theWindow.strucRgn).rgnBBox;
  989.     
  990. /*    Align the pattern to the position of the window to prevent shifting durring a drag. */
  991.         
  992.     pat->gray[0] = pat->gray[1] = ((windowRect.left^windowRect.top) & 0x0001) ? gray1Hex:gray2Hex;
  993.     
  994.     pat->black[0] = pat->black[1] = blackHex;
  995.     pat->white[0] = pat->white[1] = whiteHex;
  996.     GetPenState( &savePen );
  997.     
  998.     if ( hasColorQD )
  999.     {
  1000.         aDevice = GetDeviceList();
  1001.         do
  1002.         {
  1003.             if ( TestDeviceAttribute( aDevice, screenDevice ) &&
  1004.                                                         TestDeviceAttribute( aDevice, screenActive ) )
  1005.             {
  1006.                 HLock( aDevice );
  1007.                 if ( RectInRgn( &(**aDevice).gdRect, saveClip ) )
  1008.                 {
  1009.                     RectRgn( tempRgn, &(**aDevice).gdRect );
  1010.                     SectRgn( saveClip, tempRgn, tempRgn );
  1011.                     SetClip( tempRgn );
  1012.                     DrawOnce( param, var, window, windowRect, pat,
  1013.                                                         ((**(**aDevice).gdPMap).cmpSize >= 2 ));
  1014.                 }
  1015.                 HUnlock( aDevice);
  1016.             }
  1017.         } while ( (aDevice = GetNextDevice( aDevice )) != nil );
  1018.     } else
  1019.         DrawOnce( param, var, window, windowRect, pat, false );
  1020.     
  1021.     SetClip( saveClip );
  1022.     DisposeRgn( saveClip );
  1023.     DisposeRgn( tempRgn );
  1024.     
  1025.     SetPenState( &savePen );
  1026.     if ( savePnPat )        // Since hasColorQD may have changed, we check for presence of Handle.
  1027.     {
  1028.         RGBForeColor( &savePnClr );
  1029.         RGBBackColor( &saveBkClr );
  1030.         
  1031.         CopyPixPat( savePnPat, wPort->pnPixPat );
  1032.         CopyPixPat( saveBkPat, wPort->bkPixPat );
  1033.         CopyPixPat( saveFillPat, wPort->fillPixPat );
  1034.         DisposPixPat( savePnPat );
  1035.         DisposPixPat( saveBkPat );
  1036.         DisposPixPat( saveFillPat );
  1037.         
  1038.         SetPort( savePort );
  1039.     }
  1040. } /* end of DrawMyWindow() */
  1041.  
  1042. /*————————————————————
  1043.             draw a black and white Icon!
  1044. ————————————————————*/
  1045. PlotSICN( Rect theRect, Ptr theSICN )
  1046. {
  1047.     BitMap    srcBits;    /* built up around 'SICN' data so we can _CopyBits */
  1048.     GrafPtr    wPort;
  1049.     
  1050.     GetPort( &wPort );
  1051.  
  1052.     /* set up the small icon's bitmap */
  1053.     srcBits.baseAddr = theSICN;
  1054.     srcBits.rowBytes = 2;
  1055.     SetRect( &srcBits.bounds, 0, 0, 16, 16 );
  1056.  
  1057.                                 /* draw the small icon in the current grafport */
  1058.     CopyBits( &srcBits,&wPort->portBits,&srcBits.bounds,&theRect,srcCopy,nil );
  1059.  
  1060. } /* end of PlotSICN() */
  1061.  
  1062. /*————————————————————
  1063.             draw a color icon!
  1064. ————————————————————*/
  1065. PlotCICN( Rect theRect, Ptr theCICN )
  1066. {
  1067.     PixMap            srcBits;    // built up around 'CICN' data so we can _CopyBits
  1068.     int                i;
  1069.      CGrafPtr        wPort;            
  1070.     RGBColor        savePnClr,
  1071.                     saveBkClr,
  1072.                     myRGB;
  1073.     Handle            myCTHandle;
  1074.     AuxWinHandle    theAuxWin;
  1075.      
  1076.      myCTHandle = nil;
  1077.      theAuxWin = nil;
  1078.      
  1079.     myCTHandle = NewHandle( 40 );                            // theColorTable!
  1080.  
  1081.     if ( myCTHandle )
  1082.     {
  1083.         HLock( myCTHandle );
  1084.             
  1085.         myCTable.ctSeed = GetCTSeed();                        //    Unique Seed
  1086.         myCTable.ctFlags = 0;                                //    Empty for Color Tables
  1087.         myCTable.ctSize = 3;                                //    4 Colors
  1088.         
  1089.  
  1090.         for ( i=0; i<=3; i++ )
  1091.             myCTable.ctTable[i].value = i;                    // Colors in sequence
  1092.         
  1093.         myCTable.ctTable[1].rgb = PackGray( 0x8000 );        //    The Default Colors.
  1094.         myCTable.ctTable[3].rgb = PackGray( 0x0000 );
  1095.         
  1096.         
  1097.         GetAuxWin( nil, &theAuxWin );
  1098.         if ( theAuxWin &&
  1099.                 (*(*theAuxWin)->awCTable)->ctSize >= 12 &&
  1100.                     (*(*theAuxWin)->awCTable)->ctTable[11].rgb.red |
  1101.                             (*(*theAuxWin)->awCTable)->ctTable[11].rgb.green |
  1102.                                     (*(*theAuxWin)->awCTable)->ctTable[11].rgb.blue )
  1103.         {
  1104.                                                             // System 7 Shading Colors
  1105.             myCTable.ctTable[0].rgb = (*(*theAuxWin)->awCTable)->ctTable[11].rgb;
  1106.             myCTable.ctTable[2].rgb = (*(*theAuxWin)->awCTable)->ctTable[12].rgb;
  1107.         } else
  1108.         {
  1109.             myCTable.ctTable[0].rgb = PackGray( 0xFFFF );    //    The Default Colors.
  1110.             myCTable.ctTable[2].rgb = PackGray( 0x4000 );
  1111.         }
  1112.     }
  1113.     
  1114.     GetForeColor( &savePnClr );
  1115.     myRGB = PackGray( 0x0000 );
  1116.     RGBForeColor( &myRGB );            // Black
  1117.     GetBackColor( &saveBkClr );
  1118.     myRGB = PackGray( 0xFFFF );
  1119.     RGBBackColor( &myRGB );            // White
  1120.  
  1121.     if ( myCTHandle )
  1122.         HUnlock( myCTHandle );
  1123.  
  1124.     
  1125.      GetPort( &wPort );
  1126.      
  1127.     srcBits.baseAddr = theCICN;
  1128.      srcBits.rowBytes = 0x8004;        // bit 15 indicates PixMap
  1129.      SetRect( &srcBits.bounds, 0, 0, 16, 16 );
  1130.      srcBits.pmVersion = srcBits.packType = srcBits.pixelType = 0;
  1131.      srcBits.packSize = srcBits.planeBytes = srcBits.pmReserved = 0L;
  1132.      srcBits.hRes = srcBits.vRes = 72;
  1133.     srcBits.pixelSize = srcBits.cmpSize = 2;
  1134.      srcBits.cmpCount = 1;
  1135.      
  1136.      
  1137.      srcBits.pmTable = (CTabHandle)myCTHandle;                        // nil if not created
  1138.      
  1139.      
  1140.                                      //    draw the color icon in the current grafport
  1141.      CopyBits( &srcBits,*wPort->portPixMap,&srcBits.bounds,&theRect,srcCopy,nil );
  1142.      
  1143.     if ( myCTHandle )
  1144.         DisposHandle( myCTHandle );
  1145.         
  1146.     RGBForeColor( &savePnClr );
  1147.     RGBBackColor( &saveBkClr );
  1148. } /* end of PlotCICN() */
  1149.  
  1150. /*————————————————————
  1151.             CopyRight Notice
  1152. ————————————————————*/
  1153. CopyRight()
  1154. {
  1155.     /*    The Following Copyright Notice Is Not To Be Removed! Use Of This Code In Commercial
  1156.         Software Will Be By License Only. Contact Anthony D. Saxton, Of Elenay™ Creations
  1157.         For Licensing Information. Use Of This Code In FreeWare, Requires Only Contact Of
  1158.         Elenay™ Creations. This Copyright Applies To All Code Segments Of This WDEF. */
  1159.         
  1160.     Str63    Copyright = "Copyright©1993–Elenay™Creations,702/453–0270,"
  1161.                                 "All Rights Reserved";
  1162.     
  1163. }